package com.cuit.washneedshake.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cuit.washneedshake.model.dto.NationalTrendsResp;
import com.cuit.washneedshake.model.entity.NationalTrends;
import com.cuit.washneedshake.service.NationalTrendsService;
import com.cuit.washneedshake.mapper.NationalTrendsMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.LinkedList;


@Service
public class NationalTrendsServiceImpl extends ServiceImpl<NationalTrendsMapper, NationalTrends>
    implements NationalTrendsService {

    NationalTrendsResp nationalTrends;

    @Resource
    NationalTrendsMapper nationalTrendsMapper;

    @Override
    public LinkedList<NationalTrendsResp> getNationalTrendsInfo(){
        LinkedList<NationalTrendsResp> resList = new LinkedList<>();

        for(int i = 1;i <= 15;i ++){
            nationalTrends = new NationalTrendsResp();
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM.dd");
            String date = simpleDateFormat.format(nationalTrendsMapper.getDate(i));
            nationalTrends.setDate(date);
            nationalTrends.setConfirmed(nationalTrendsMapper.getConfirmedById(i));
            nationalTrends.setCured(nationalTrendsMapper.getCuredById(i));
            nationalTrends.setDeath(nationalTrendsMapper.getDeathById(i));
            resList.add(nationalTrends);
        }
        return resList;

    }


}




